<template>
  <div class="nav_title">
    <div class="left_box">
      <svg-icon :icon-class="routerInfo.meta.icon?routerInfo.meta.icon:''"></svg-icon>
      <span class="metaTitle">{{  tableName ? tableName : routerInfo.meta.title }}</span>
    </div>
    <slot></slot>
  </div>
</template>

<script>
export default {
  name: "navigation-title",
  components: {},
  props: {
    breadList: {
      type: Array,
      default: () => {
        return [];
      }
    },
    tableName: {
        type: String,
        default: null
      }
  },
  data() {
    return {
      routerInfo: null
    };
  },
  watch: {
    $route: {
      handler(to, from) {
        this.routerInfo = to;
      },
      deep: true, // 深度监听
      immediate: true // 第一次初始化渲染就可以监听到
    }
  },
  mounted() {},
  methods: {
    /**面包屑点击事件 */
    breadRouterClick(item) {
      this.$emit("breadRouterClick", item);
    }
  }
};
</script>
<style scoped lang="scss">
.nav_title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 20px;
  border-bottom: 1px solid #eee;
  .left_box {
    display: flex;
    align-items: center;
    color: #999;
    font-size: 15px;
  }
}
.metaTitle {
  margin-left: 8px;
  color: #333;
}
</style>
